<template>
<div>
  <h4 class="header">vue期末作品</h4>
  <div class="ss">
    <el-form status-icon label-width="100px" class="demo-ruleForm">
      <el-form-item label="账号" prop="pass">
        <el-input type="text" v-model="pass" autocomplete="off" ref="pass" ></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="checkPass">
        <el-input type="password" v-model="checkPass" autocomplete="off" ref="checkPass"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" :plain="true" @click="submitForm()">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</div>
</template>
<script>
export default {
  name: "myLogin",
  data() {
    return {
        pass: '',
        checkPass: '',

    };
  },
  methods: {
    submitForm() {
      // 校验
      var admin=this.$refs.pass.value
      var password=this.$refs.checkPass.value
      if (admin===''||password===''){
        this.$message.error('请检查 账号,密码不能为空');
      }else {
        // this.$message({
        //   message: '登录成功',
        //   type: 'success',
        // });
        // 登录成功并跳转路由
        this.$router.push('/home')
      }
      },
  }
}
</script>
<style scoped>
    .ss{
      width: 400px;
      height: 300px;
      margin: auto;
    }
    .header{
      width: 400px;
      height: 45px;
      margin: auto;
      padding-left:300px ;
    }
    .el-button{
      width: 300px;
    }
</style>